from django.http import JsonResponse
from django.views import View
from rest_framework.views import APIView
from rest_framework.response import Response
from extend.auth import MyAuthentication, Authentication1, NoAuthentication
from extend.permission import MyPermission
from extend.views import NewView

# django_api start
response = {'start': True, "massage": "GET"}


# fbv
def d1(request):
    if request.mothod == "GET":
        return JsonResponse(response)


# cbv
class Class1(View):

    def get(self, request, *args, **kwargs):
        return JsonResponse(response)


# django_api end


# django rest framework cbv
class DrfClass(NewView):
    authentication_classes = [MyAuthentication]  # 局部配置认证类使用
    permission_classes = [MyPermission]  # 局部配置权限类

    def get(self, request, *args, **kwargs):
        print(request.user, request.auth)
        return Response({'start': True})

